****************************************
* Johnson Karpoff and Yi               *
* Author: William C. Johnson           *
* date: 07-07-2021                     *
* Submitted code to the RFS            *
****************************************



****************************************
* The purpose of this code is to       *
* generate the results in table 5      *
* from Johnson, Karpoff, and Yi.       *
* Since this table uses the universe   *
* of CRSP/COMPUSTAT firms, we generate *
* this table separately from the other *
* data in the paper.                   *
* The data in this table is generated  *
* following a Faulkender and Wang 2006 *
* procedure with some modifications as *
* outlined in the paper.               *
****************************************
* To execute this code to generate     *
* table 5 the user must first place    *
* the dataset Table_5_data_final_RFS   *
* into the c:/data directory.          *
* This dataset contains the universe   *
* of CRSP/COMPUSTAT firms that pass    *
* the screens for Faulkender and Wang  *
* (2006). Major results from the       *
* regressions will be put in an Excel  *
* file in the directory c:/data.       *
****************************************


set more 1
clear
set memory 320m
capture log close


clear
use "C:\data\Table_5_data.dta", replace

reg adjustedreturn delta_cust_sale delta_division_sales2 deltafounder deltacash delta_diversifying deltaCEOchair deltaE deltanetassets deltaRD deltaI deltaDIV C L NF , robust
estimates store n1, title(Model 1)
	reg adjustedreturn delta_cust_sale delta_division_sales2 deltafounder deltacash delta_diversifying deltaCEOchair deltaE deltanetassets deltaRD deltaI deltaDIV C L NF  if age<=5, robust
estimates store n2, title(Model 2)
	reg adjustedreturn delta_cust_sale delta_division_sales2 deltafounder deltacash delta_diversifying deltaCEOchair deltaE deltanetassets deltaRD deltaI deltaDIV C L NF  if age>5 & age<=9, robust
estimates store n3, title(Model 3)
	reg adjustedreturn delta_cust_sale delta_division_sales2 deltafounder deltacash delta_diversifying deltaCEOchair deltaE deltanetassets deltaRD deltaI deltaDIV C L NF  if age>=10, robust
estimates store n4, title(Model 4)
	

esttab n1 n2 n3 n4 using "c:/data/table5a_RFS_FINAL.csv", replace  ///
cells(b(fmt(%9.3f) star) se(par) ) ///
starlevels(* .1 ** 0.05 *** .01) ///
stats(N r2, labels("Observations" "R-squared") ///
fmt(%9.0f %9.3f)) ///
varlabels( delta_cust_sale "customer sales" delta_division_sales2 "durable sales" ///
 deltafounder2 "founder" deltacash "delta cash" delta_diversifying "diversifying acquisitions" ///
 deltaCEOchair "CEO chair" deltaE "delta E" deltanetassets "delta NA" deltaRD "deltaRD" ///
 deltaI "deltaI" deltaDIV "deltaDIV" C "C" L "L" NF "net financing"  ///
collabels(,none) mlabels(,none) ///
order(delta_cust_sale delta_division_sales deltafounder deltacash delta_diversifying deltaCEOchair deltaE deltanetassets deltaRD deltaI deltaDIV C L NF) ///
prehead() ///
prefoot() ///
indicate()) 

*this code tests the differences in the coefficients tabulated in the last column of the table 5a.
*the code generates the t-stats reported in the table.)
gen old=1 if age>=10
replace old=0 if age<=5
gen test_sig_cash=old*deltacash
gen test_sig_diversifying=old*delta_diversifying
gen test_sig_CEO=old*deltaCEOchair
gen test_sig_cust=old*delta_cust_sale
gen test_sig_durable=old*delta_division_sales2
gen test_sig_founder=old*deltafounder
reg adjustedreturn delta_cust_sale test_sig_cust delta_division_sales2 test_sig_durable deltafounder test_sig_founder deltacash old test_sig_cash  delta_diversifying test_sig_diversifying deltaCEOchair test_sig_CEO deltaE deltanetassets deltaRD deltaI deltaDIV C L NF , robust

estimates store n5, title(Model 5)


esttab n5 using "c:/data/table5a_tstats_RFS_FINAL.csv", replace  ///
cells(b(fmt(%9.3f) star) t(par) ) ///
starlevels(* .1 ** 0.05 *** .01) ///
stats(N r2, labels("Observations" "R-squared") ///
fmt(%9.0f %9.3f)) ///
varlabels( test_sig_cash "test of cash coeff" test_sig_diversifying "test of diversifying acq coeff" ///
 test_sig_CEO "test of CEO chair coeff" test_sig_cust "test of customer coeff" test_sig_durable "test of durable prod sale coeff" ///
 test_sig_founder "test of founder coeff"  ///
collabels(,none) mlabels(,none) ///
order(test_sig_cash  test_sig_diversifying  test_sig_CEO  test_sig_cust test_sig_durable  test_sig_founder  ) ///
prehead() ///
prefoot() ///
indicate()) 

*generate results for table 5.B
 sum  cashvalue acquisitionvalue  CEOchair_value   customervalue durable_sales_value foundervalue NPV
sum  cashvalue acquisitionvalue  CEOchair_value   customervalue durable_sales_value foundervalue NPV if timefromipo<=5
sum  cashvalue acquisitionvalue  CEOchair_value   customervalue durable_sales_value foundervalue NPV if timefromipo>5 & timefromipo<=9
sum  cashvalue acquisitionvalue  CEOchair_value   customervalue durable_sales_value foundervalue NPV if timefromipo>=10

